window.onload = function(){
  var btnTag = document.querySelector('#btnDL');

  btnTag.onclick = function(){
    var name = document.querySelector('#user').value;
    var pass = document.querySelector('#pass').value;
    setCookie('user',name,2);
    setCookie('pass',pass,2);
  }
$(document).ready(function() {
  var userTag = getCookie('user');
  var passTag = getCookie('pass');
  if (userTag) {
    $('#btnTag').text(userTag + '已登录');
  }else{
    $('#btnTag').text('请登录');
  }
  // checkCookie();
});

  function checkCookie(){
    user = getCookie('user');
    if (user!=null && user!=""){
      alert('Welcome again ' + user + '!')
    }else{
      user = prompt('Please enter your name:',"")
      if (user != null && user != ""){
        setCookie('user',user,2)
        }
      }
    }
  }
